package com.wangbo.ocr;

import com.alibaba.fastjson.JSON;
import com.aliyun.ocr20191230.Client;
import com.aliyun.ocr20191230.models.RecognizeCharacterAdvanceRequest;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.teautil.models.RuntimeOptions;
import lombok.SneakyThrows;
import java.io.FileInputStream;


public class TestOcr {
    public static void main(String[] args) {

    }

    public static void test01() throws Exception {
        Config config = new Config();
        config.accessKeyId = "LTAI5tA2HFaW1Ky5VK8bV6Lg";
        config.accessKeySecret = "F1ltkLnfSr1GYSaqZdZ8gy15NgHKYx";

        config.type="access_key";
        config.regionId="cn-shanghai";

        // config.endpointType="internal";  //默认通过公网访问OSS，如需通过内网请打开这一行
        Client client = new Client(config);
        RuntimeOptions runtimeOptions = new RuntimeOptions();
        //url方式
        recognizeCharacterAdvance(client,runtimeOptions);
        config.endpoint="ocr.cn-shanghai.aliyuncs.com";
        //此处endpoint以文字识别为例。不同服务的Endpoint参见访问域名。
    }


    @SneakyThrows
    public static void recognizeCharacterAdvance(Client client, RuntimeOptions runtimeOptions) {
        RecognizeCharacterAdvanceRequest request = new RecognizeCharacterAdvanceRequest();
        request.imageURLObject = new FileInputStream("");
        client.recognizeCharacterAdvance(request, runtimeOptions);
        System.out.println("文字识别="+ JSON.toJSONString(request));
    }
}
